//
//  ZCdetectionPostCell.m
//  zctx
//
//  Created by apple on 16/1/8.
//  Copyright © 2016年 sanliang. All rights reserved.
//

#import "ZCdetectionPostCell.h"

@implementation ZCdetectionPostCell

- (void)awakeFromNib {
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = RGB(245, 245, 245);
    self.ontLable.textColor = [UIColor colorWithHexString:@"#525252"];
    self.twoLable.textColor = [UIColor colorWithHexString:@"#525252"];
    
    self.oneBGview.layer.borderWidth = 1;
    self.oneBGview.layer.borderColor = RGB(226, 226, 226).CGColor;
    self.twoBGview.layer.borderWidth = 1;
    self.twoBGview.layer.borderColor = RGB(226, 226, 226).CGColor;
    self.oneBGview.backgroundColor = [UIColor whiteColor];
    self.twoBGview.backgroundColor = [UIColor whiteColor];
    
    self.lineView.backgroundColor =RGB(226, 226, 226);
    self.linetwoView.backgroundColor =RGB(226, 226, 226);
    
    self.bgView.backgroundColor =RGB(226, 226, 226);
    self.tbgView.backgroundColor =RGB(226, 226, 226);

    
    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapClick:)];
    [self.OneimgView addGestureRecognizer:recognizer];
    
    UITapGestureRecognizer *recognizerTWO = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapClick:)];
    [self.OneimgView addGestureRecognizer:recognizer];
    [self.TwoimgView addGestureRecognizer:recognizerTWO];
}

-(void)setModel:(ZCInvolvedDetailsModelContent *)model{
    _model = model;
    NSLog(@"model.prot = %ld , = %ld",model.samples.count,model.testreportJpg.count);
    
    if (model.samples.count>0) {
        for (NSDictionary *item in model.samples) {
            if ([item isKindOfClass:[NSDictionary class]]) {
                NSObject *obj =(NSObject *)[item objectForKey:@"img_url"];
                if ([obj isKindOfClass:[NSString class]]) {
                    NSString *str = (NSString *)obj;
                    if (str.length>0) {
                        NSString *urlstr = [NSString stringWithFormat:@"%@%@",[NetworkManager strURLBasic],[item objectForKey:@"img_url"]];
                        [self.imgArray addObject:urlstr];
                    }
                }
            }
        }
    }
    
    if (model.testreportJpg.count>0) {
        for (NSDictionary *item in model.testreportJpg) {
            if ([item isKindOfClass:[NSDictionary class]]) {
                NSObject *obj =(NSObject *)[item objectForKey:@"img_url"];
                if ([obj isKindOfClass:[NSString class]]) {
                    NSString *str = (NSString *)obj;
                    if (str.length>0) {
                        NSString *urlstr = [NSString stringWithFormat:@"%@%@",[NetworkManager strURLBasic],[item objectForKey:@"img_url"]];
                    
                        [self.testArray addObject:urlstr];
                    }
                }
            }
        }
    }
    if (self.testArray.count>0) {
        [self.TwoimgView sd_setImageWithURL:[NSURL URLWithString:self.testArray[0]] placeholderImage:[UIImage imageNamed:@"placehold_detection"]];
    }else{
        self.TwoimgView.image =[UIImage imageNamed:@"placehold_detection"];
    }
    if (self.imgArray.count>0) {
        [self.OneimgView sd_setImageWithURL:[NSURL URLWithString:self.imgArray[0]] placeholderImage:[UIImage imageNamed:@"placeholderImg"]];
    }else{
        self.OneimgView.image =[UIImage imageNamed:@"placeholderImg"];
    }

    self.numOneLable.text = [NSString stringWithFormat:@"%ld张",self.imgArray.count];
    self.numTwoLabel.text = [NSString stringWithFormat:@"%ld张",self.testArray.count];
}

-(void)TapClick:(UITapGestureRecognizer *)recognizer{
    NSMutableArray *array = [[NSMutableArray alloc]init];
    if (recognizer.view.tag ==0) {
        array = self.imgArray;
    }else{
        array = self.testArray;
    }
    NSLog(@"model.prot = %@",array);
    if (_delegate &&[_delegate respondsToSelector:@selector(ClickImgViewZCdetection:)]) {
        [_delegate ClickImgViewZCdetection:array];
    }
}

-(NSMutableArray *)imgArray{
    if (!_imgArray) {
        _imgArray = [[NSMutableArray alloc]init];
    }
    return _imgArray;
}

-(NSMutableArray *)testArray{
    if (!_testArray) {
        _testArray = [[NSMutableArray alloc]init];
    }
    return _testArray;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
